package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.dto.BrandDTO;
import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {


    @Insert("insert into tb_category_brand " +
            "values (#{categoryId},#{brandId})")
    boolean addCategoryBrand(@Param("categoryId") Integer categoryId, @Param("brandId") Long brandId);

    @Delete("delete from tb_category_brand where brand_id = #{id}")
    boolean deleteCategoryBrand(@Param("id") Long id);


    @Select("select tbb.* " +
            "from tb_brand as tbb,tb_category_brand as tcb " +
            "where tbb.id = tcb.brand_id " +
            "and tcb.category_id = #{id} ")
    List<BrandDTO> queryBrandByCategoryId(@Param("id") Long id);
}
